package LeetCode;

public class DisappearingNumbers {
    public static void main(String[] args) {
        int[] arr = {9,6,4,2,3,5,7,0,1};
        System.out.println(disappearing(arr));

    }

    public static int disappearing(int[] arr) {

        int data = 0;
        for (int i = 0; i < arr.length; i++) {
            data ^= arr[i];
            data ^= i;
        }
        data ^= arr.length;
        return data;
    }

    public static int disappearing1(int[] arr) {
        int sum1 = 0;
        int sum2 = 0;
        for (int i = 0; i < arr.length; i++) {
            sum1 += i;
            sum2 += arr[i];
        }
        return (sum1 += arr.length) - sum2;
    }
}
